package com.winchain.chainbill.bill.biz.transfer.rx;

import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.po.CbDfrl;
import com.winchain.chainbill.bill.base.po.CbXfe;
import com.winchain.chainbill.bill.base.service.CbDfrlService;
import com.winchain.chainbill.bill.biz.BillEvent;
import com.winchain.chainbill.bill.biz.transfer.vo.BillXfe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillDfrlSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<CbXfe>> {
	@Autowired
	private CbDfrlService cbDfrlService;

	public void onApplicationEvent(BillEvent<CbXfe> t) {
		BillXfe billXfe = (BillXfe) t.getBill();
		CbDfrl cbDfrl = billXfe.getDfrl();
		if (cbDfrl != null) {
			this.cbDfrlService.saveOrUpdate(cbDfrl);
		}
	}
}
